{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from torch import nn,optim\n",
    "from torch.autograd import Variable\n",
    "import torch\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzt3X+03HV95/HnKzc3EqQSXNI99QYkrRGNYo2OqM0WhKKJehqougoup7Biaa3sH8XmNKyuWjwuKTna1S22pJZj61YRrLJxgc26EtfVY9zcbECbYDSiQG485boSejQRbm7e+8fMhG/mznfmMzPf+f16nMM5d77z+X7n8xV8z2fen8/3/VFEYGZm42FRvztgZma946BvZjZGHPTNzMaIg76Z2Rhx0DczGyMO+mZmY8RB38xsjDjom5mNEQd9M7MxsrjfHah15plnxjnnnNPvbpiZDZXdu3f/JCKWN2s3cEH/nHPOYXp6ut/dMDMbKpIeTmnn9I6Z2Rhx0DczGyMO+mZmY8RB38xsjDjom5mNEQd9M7Mx4qBvZjZGHPTNzMaIg76Z2Rhx0DczGyMO+mZmY8RB38xsjDjom5mNkaSgL2m9pP2SDkjaVOf9P5D0HUn3S/q6pNWV46+VtLvy3m5JFxd9A2Zmlq5p0Jc0AdwCvB5YDVxRDeoZn4mI8yLipcDNwEcrx38C/HZEnAdcBXy6sJ6bmVnLUkb65wMHIuKhiHgKuB24NNsgIv458/KZQFSO74mIQ5Xje4FTJD2j826bmVk7UjZRmQIezbw+CLyytpGkdwPXA0uAemmcNwN7IuLJNvppZmYFSBnpq86xWHAg4paI+DXgT4D3nXQB6UXAnwG/X/cDpG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cCLia8BPGzS5FPi7KNsJLJP0K0X2YZiDfsqG7SfaRHkzmCeAf9GT3nVHq5vUX0N51DCsmt6vpDXAWRHx33rZsS5J+ff7fOD5kr4haaek9T3rXXek3PMHgSsrGzXdA/y73nStL1r9/3jLFhd5sR5L2bC97U3dB1Ty/Ui6EihR3qJyWDW8X0mLgD8Hru5Vh7os5d/vYsopntdQ/hX3vyW9OCIOd7lv3ZJyz1cAn4qIj0h6NfDpyj0f7373eq7rMWuYR/opG7afaCNpMeWfho1+Wg26pE3qJV0CvBfYEBFP9qhv3dDsfn8JeDHwVUk/opwD3TbEk7mp/03/14iYi4gfAvspfwkMq5R7vga4AyAivgmcQrlOzShK+v94J4Y56Kds2L4NuKry91uA+6IyWzKkmt5zJd1xK+WAP+z53ob3GxFPRMSZEXFORJxDeQ5jQ0QM636bKf9N30V5sh5JZ1JO9zzU014WK+WeHwF+C0DSCykH/dme9rJ3tgG/W1mgWOUaAAAAw0lEQVTF8yrgiYj4cZEfMLTpnYg4Jqm6YfsEcFtUNmwHpiNiG/A3lH8KHqA8wr+8fz3uXOI9bwFOA+6szFk/EhEb+tbpDiTe78hIvN/twOsk7QPmgY0R8f/61+vOJN7ze4C/lvRHlFMdVw/r4E3SZymn5s6szFF8AJgEiIi/ojxn8QbgAHAE+LeF92FI/7czM7M2DHN6x8zMWuSgb2Y2Rhz0zczGiIO+mdkYcdA3MxsjDvpmZmPEQd/MbIw46JuZjZH/Dw5V/d/mXT9eAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_data = np.random.rand(100)# 生成100个随机数\n",
    "noise = np.random.normal(0,0.01,x_data.shape)# 生成指定均值和标准差的高斯分布（正态分布）样本\n",
    "y_data = x_data*0.1 + 0.2 + noise\n",
    "\n",
    "plt.scatter(x_data,y_data)#话散点图\n",
    "plt.show()#显示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_data = x_data.reshape(100,1)#reshape(a,b)函数改变xdata的维度为a行b列\n",
    "y_data = y_data.reshape(-1,1)#-1代表自动匹配data的原本行数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "#把numpy数据变成tensor\n",
    "x_data = torch.FloatTensor(x_data)\n",
    "y_data = torch.FloatTensor(x_data)\n",
    "input = Variable(x_data)\n",
    "target = Variable(y_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 构建神经网络模型\n",
    "# nn.Module是PyTorch中所有神经网络模块的基类\n",
    "class LinearRegression(nn.Module):\n",
    "    #定义网络结构，一般将网络中具有可学习参数的层放在__init__()中\n",
    "    def __init__(self):\n",
    "        # 初始化nn.module\n",
    "        super(LinearRegression, self).__init__()\n",
    "        self.fc = nn.Linear(1, 1)#一个输入对应一个输出\n",
    "    # 定义网络计算，输入x，根据nn.Linear自动生成的参数计算out\n",
    "    def forward(self, x):\n",
    "        out = self.fc(x)\n",
    "        return out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义模型\n",
    "model = LinearRegression()\n",
    "# 定义损失函数\n",
    "mse_loss = nn.MSELoss()\n",
    "# 定义优化器，用于调整权值，这里使用的是梯度下降法，第一个参数是模型的参数，第二个参数是学习率\n",
    "optimizer = optim.SGD(model.parameters(), lr=0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:fc.weight, param:Parameter containing:\n",
      "tensor([[0.4600]], requires_grad=True)\n",
      "name:fc.bias, param:Parameter containing:\n",
      "tensor([-0.8589], requires_grad=True)\n"
     ]
    }
   ],
   "source": [
    "# 定义好模型后可以查看一下这个模型都有哪些参数\n",
    "for name, parameters in model.named_parameters():\n",
    "    print('name:{}, param:{}'.format(name, parameters))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 1.3513827323913574\n",
      "200 3.122846123915224e-07\n",
      "400 1.1226535256980696e-09\n",
      "600 4.110387377687097e-12\n",
      "800 2.246569087444722e-13\n",
      "1000 2.2436356429417909e-13\n"
     ]
    }
   ],
   "source": [
    "# 开始模型的训练\n",
    "for i in range(1001):\n",
    "    out = model(input)\n",
    "    # 计算loss\n",
    "    loss = mse_loss(out, target)\n",
    "    # 梯度清零\n",
    "    optimizer.zero_grad()\n",
    "    # 计算梯度\n",
    "    loss.backward()\n",
    "    # 调整权值\n",
    "    optimizer.step()\n",
    "    if i%200 == 0:\n",
    "        print(i,loss.item())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAHKdJREFUeJzt3Xt8VOW97/HPjxg01Au6qac1QIOKVUQUzBGVdte7eIPQWgWl1W4P7Fqx9UYDu1SpO25QWm+ndLvRur1WvJw6xoiHtqhHT45YsINEYNMNBCGDR6mKPbW0Ff2dPyaDQ8yaWSFzXfN9v168XjNZj8lvmfDlybOei7k7IiISLX2KXYCIiOSewl1EJIIU7iIiEaRwFxGJIIW7iEgEKdxFRCJI4S4iEkEKdxGRCFK4i4hE0B7F+sIDBgzwurq6Yn15EZGy9Oqrr/7B3T+brV3Rwr2uro7ly5cX68uLiJQlM3sjTDsNy4iIRJDCXUQkghTuIiIRpHAXEYkghbuISAQp3EVEI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sA5SzrPZvZSGCQu7cUsrA8CfM9Pgw4zMxazWypmY0tWHW5F+Z+ZwOTzayD5KlvVxamtKLp6d/zHgt1zF6RddcD7zrFJ0ybchH6XsxsMlAPfCWvFeVfxns2sz7AbcClhSooz8J8j/cgOTRzEsnfzF4ys+Huvi3PteVDmPudBNzn7j8xsxNInsk83N0/zn95RZH3zCqHnnsHMCjt/UA+/SvbzjZmtgfJX+sy/UpUysLcL2Z2GvADYJy7/7VAteVLtnveBxgOvGBmG0mOUTaX8UPVsD/TT7n7h+7eDqwlGfblKMz9XgY8BuDuLwN7kdyDJapC/T3vjXII92XAUDMbYmZ9ST4wbe7Sphm4pPP1+cBz3vnUogxlvd/OIYp/Ixns5TwWm5Lxnt39fXcf4O517l5H8jnDOHdfXpxyey3Mz3SM5INzzGwAyWGaDQWtMnfC3O8m4FQAMzuCZLhvLWiVhdUMfLNz1szxwPvu/mZOv0KxnyqHfPJ8NvB7kk/cf9D5sRtJ/gWH5A/C48A64LfAwcWuOc/3+xvgLWBF55/mYtec73vu0vYFyni2TMjvsQG3AquBNmBisWvO8/0OA1pJzqRZAZxR7Jp7eb+PAG8CH5LspV8GfBv4dtr3d37n/4+2fPw8a4WqiEgElcOwjIiI9JDCXUQkghTuIiIRpHAXEYkghbuISAQp3EVEIkjhLiISQQp3EZEI+v+G/djYpu2ryAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 测试\n",
    "y_pred = model(input)\n",
    "plt.scatter(x_data, y_data)\n",
    "plt.plot(x_data, y_pred.data.numpy(), 'r-', lw = 3)\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
